import http2 from "@/api/http2";
/**获取镜像列表 */
export const getMirrorList = data => {
  return http2.get(`/v1/image/list?server_id=${data}`);
};
/*用户获取镜像列表 */
export const getUserMirrorList = data => {
  return http2.get(
    `/v1/image/list?server_id=${data.server_id}&count=${data.count}&page=${data.page}&key=${data.key}`
  );
};
/**上传镜像 */
export const uploadMirror = data => {
  return http2.post("/v1/image/pull", data, {
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
};
/**编辑镜像 */
export const editMirror = data => {
  return http2.post("/v1/image/update", data, {
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
};
/**删除镜像 */
export const delMirror = data => {
  return http2.post("/v1/image/delete", data, {
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
};
/**镜像同步 */
export const syncMirror = data => {
  return http2.get(`/v1/image/sync?server_id=${data}`);
};
/**重新拉取镜像 */
export const pullMirror = data => {
  return http2.post(`/v1/image/repull`, data, {
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
};

/**获取镜像信息 */
export const Mirrorinfo = data => {
  const serverType = data.server_type || "dockerContainer"; // 设置默认值
  return http2.get(
    `/v1/image/info?image_id=${data.image_id}&server_type=${serverType}`
  );
};

export const addVirtualMirror = data => {
  return http2.post("/v1/image/create", data, {
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
};
